home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / GENCSRC.ZIP / SHIFTER.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  584b  |  25 lines

  1.                                          /* Chapter 13 - Program 4 */
  2. main()
  3. {
  4. int small, big, index, count;
  5.  
  6.    printf("       shift left      shift right\n\n");
  7.    small = 1;
  8.    big = 0x4000;
  9.    for(index = 0;index < 17;index++) {
  10.       printf("%8d %8x %8d %8x\n",small,small,big,big);
  11.       small = small << 1;
  12.       big = big >> 1;
  13.    }
  14.  
  15.    printf("\n");
  16.    count = 2;
  17.    small = 1;
  18.    big = 0x4000;
  19.    for(index = 0;index < 9;index++) {
  20.       printf("%8d %8x %8d %8x\n",small,small,big,big);
  21.       small = small << count;
  22.       big = big >> count;
  23.    }
  24. }
  25.